﻿using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TomatoClock.Models
{
    public class Data_Achievement_Association
    {
        public int UserId {  get; set; }
        public int AchievementId { get; set;}
        public bool IsAchieved { get; set; }
        public DateTime AchievedDate { get; set; }

        public Data_Achievement_Association(int userId, int achievementId, bool isAchieved, DateTime achievedDate)
        {
            UserId = userId;
            AchievementId = achievementId;
            IsAchieved = isAchieved;
            AchievedDate = achievedDate;
        }
        public Data_Achievement_Association() { 
        }
        // 注册自定义类型处理器
        public class BoolHandler : SqlMapper.TypeHandler<bool>
        {
            public override void SetValue(IDbDataParameter parameter, bool value)
            {
                parameter.Value = value ? 1 : 0;
            }

            public override bool Parse(object value)
            {
                return value.ToString() == "1";
            }
        }      
    }
}
